<template>
  <div>
    <ul v-for="item in arr" :key="item.id">
      <li>{{ item.number }} <button @click="del(item.id)">删除</button></li>
    </ul>
    <button @click="add()">添加</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr: [
        // { id: 11, number: 22 },
      ]
    }
  },
  methods: {
    add () {
      this.arr.push({
        id: +new Date(),
        number: Math.floor(Math.random() * 20)
      })
    },
    del (id) {
      this.arr = this.arr.filter(item => item.id !== id)
    }
  }
}
</script>

<style></style>
